package rmi;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;

public class HelloService extends UnicastRemoteObject implements MyRemote{

    protected HelloService() throws RemoteException {
        super();
        
    }

    @Override
    public String sayHello(String s) throws RemoteException{
        System.err.println(s);
        return s;
    }
    
    public static void main(String[] args) throws Exception {
        LocateRegistry.createRegistry(1009);
        Remote helloService = new HelloService();
        try {
            Naming.rebind("rmi://192.168.2.13:1009/RemoteHello", helloService);
        } catch (RemoteException e) {
            
            e.printStackTrace();
        } catch (MalformedURLException e) {
            
            e.printStackTrace();
        }
    }
}
